package com.ruoyi.csdn.service.impl;

import java.util.List;

import com.ruoyi.common.constant.ServiceConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.csdn.domain.CsdnUser;
import com.ruoyi.csdn.mapper.CsdnUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.csdn.mapper.CsdnArticleMapper;
import com.ruoyi.csdn.domain.CsdnArticle;
import com.ruoyi.csdn.service.ICsdnArticleService;

/**
 * CSDN文章发布Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-30
 */
@Service
public class CsdnArticleServiceImpl implements ICsdnArticleService
{
    @Autowired
    private CsdnArticleMapper csdnArticleMapper;

    @Autowired
    private CsdnUserMapper csdnUserMapper;

    /**
     * 查询CSDN文章发布
     * 
     * @param id CSDN文章发布主键
     * @return CSDN文章发布
     */
    @Override
    public CsdnArticle selectCsdnArticleById(Long id)
    {
        return csdnArticleMapper.selectCsdnArticleById(id);
    }

    /**
     * 查询CSDN文章发布列表
     * 
     * @param csdnArticle CSDN文章发布
     * @return CSDN文章发布
     */
    @Override
    public List<CsdnArticle> selectCsdnArticleList(CsdnArticle csdnArticle)
    {
        return csdnArticleMapper.selectCsdnArticleList(csdnArticle);
    }

    /**
     * 新增CSDN文章发布
     * 
     * @param csdnArticle CSDN文章发布
     * @return 结果
     */
    @Override
    public int insertCsdnArticle(CsdnArticle csdnArticle)
    {
        csdnArticle.setCreateTime(DateUtils.getNowDate());
        return csdnArticleMapper.insertCsdnArticle(csdnArticle);
    }

    /**
     * 修改CSDN文章发布
     * 
     * @param csdnArticle CSDN文章发布
     * @return 结果
     */
    @Override
    public int updateCsdnArticle(CsdnArticle csdnArticle)
    {
        csdnArticle.setUpdateTime(DateUtils.getNowDate());
        return csdnArticleMapper.updateCsdnArticle(csdnArticle);
    }

    /**
     * 批量删除CSDN文章发布
     * 
     * @param ids 需要删除的CSDN文章发布主键
     * @return 结果
     */
    @Override
    public int deleteCsdnArticleByIds(Long[] ids)
    {
        return csdnArticleMapper.deleteCsdnArticleByIds(ids);
    }

    /**
     * 删除CSDN文章发布信息
     * 
     * @param id CSDN文章发布主键
     * @return 结果
     */
    @Override
    public int deleteCsdnArticleById(Long id)
    {
        return csdnArticleMapper.deleteCsdnArticleById(id);
    }

    /**
     * 查找所有的CSDN用户
     * @return
     */
    @Override
    public List<CsdnUser> listcsdnuser() {
        CsdnUser csdnUser=new CsdnUser();
        csdnUser.setUserStatus(ServiceConstants.CSDN_USER_STATUS_START);
        List<CsdnUser> csdnUsers = csdnUserMapper.selectCsdnUserList(csdnUser);
        return csdnUsers;
    }
}
